package com.kaili.basic.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.kaili.basic.pojo.dto.MdmDatadictDto;
import com.kaili.basic.pojo.entity.MdmDatadictEntity;
import com.kaili.basic.pojo.vo.MdmDatadictVo;
import com.kaili.common.util.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.kaili.basic.service.IDatadictService ;
import com.kaili.basic.mapper.DatadictMapper;

import java.util.HashMap;
import java.util.List;

/**
* 数据字典 service实现类
* @author:liuyang
* @Time: 2019-07-23
* @Copyright: ©  杭州凯立通信有限公司 版权所有
* @Warning: 本内容仅限于公司内部传阅,禁止外泄或用于其它商业目的
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class DatadictServiceImpl extends ServiceImpl<DatadictMapper, MdmDatadictEntity>  implements IDatadictService {

	@Override
	public MdmDatadictVo queryById(Integer id) {
		List<MdmDatadictVo> list = baseMapper.queryList(new HashMap<String, Object>(2) {{put("id", id);}});
		if(list !=null && list.size()>0){
			return list.get(0);
		}

		return null;
	}

	@Override
	public List<MdmDatadictVo> queryList(MdmDatadictDto dto) {
		return baseMapper.queryList(ObjectUtils.objectToMap(dto));
	}
}
